home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / PROBLEMS / ASM / DIVASM < prev    next >
Internet Message Format  |  1992-03-08  |  1KB

  1. Path: newcastle.ac.uk!uknet!ukc!mcsun!fuug!news.funet.fi!sunic!dkuug!diku!torbenm
  2. >From: torbenm@diku.dk (Torben AEgidius Mogensen)
  3. Newsgroups: comp.sys.acorn
  4. Subject: Re: fast divide
  5. Message-ID: <1991Oct31.153421.22641@odin.diku.dk>
  6. Date: 31 Oct 91 15:34:21 GMT
  7. References: <3351@m1.cs.man.ac.uk>
  8. Sender: torbenm@freke.diku.dk
  9. Organization: Department of Computer Science, U of Copenhagen
  10. Lines: 41
  11.  
  12. rogersh%t3b@uk.ac.man.cs (Huw J. Rogers) writes:
  13.  
  14.  
  15. >    Can people post/email the fastest 32 bit divide/modulus
  16. >routines they have for the ARM? ObjAsm stuff is preferred, but
  17. >BASIC assembler (ugh!) will do... ;-)
  18.  
  19. Here is one I cooked up. It is from memory, so there might be slight
  20. errors. The comparisons before the first SUB ensure that no overflow
  21. happens on the ASL. Worst case time is 5 cycles per bit.
  22.  
  23. Arguments in p,q.
  24. on exit, r = p div q, p = p mod q
  25.  
  26. .div
  27.  MOV r,#0
  28.  CMP p,q
  29.  BLT nodiv
  30.  CMP p,q ASL #1
  31.  BLT div0
  32.  CMP p,q ASL #2
  33.  BLT div1
  34.  ...            \ repeat for 3..30
  35.  CMP p,q ASL #31
  36.  SUBGE p,q ASL #31
  37.  ADDGE r,#2^31
  38.  CMP p,q ASL #30
  39. .div30
  40.  SUBGE p,q ASL #30
  41.  ADDGE r,#2^30
  42.  CMP p,q ASL #29
  43. .div29
  44.  ...            \ repeat for 29..1
  45. .div0
  46.  SUBGE p,q ASL #0    \ equiv. to SUBGE p,q
  47.  ADDGE r,#2^0
  48. .nodiv
  49.  MOV PC,Link
  50.  
  51.  
  52.  
  53.  
  54.